package com.core.dao;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;

import javax.persistence.Column;
import javax.persistence.Entity;

import com.dpmc.entity.TB_HYKGL_KZXX; 

public class AnnotationTest {
	public static void main(String[] args) {
		SQLBuilder builder = new SQLBuilder();
		System.out.println(builder.insertSQL(TB_HYKGL_KZXX.class));
		System.out.println(builder.updateSQL(TB_HYKGL_KZXX.class));
		System.out.println(builder.deleteSQL(TB_HYKGL_KZXX.class));
	}
	
	

	/**
	 * @param args
	 */
	public static void main22(String[] args) {
		Class c=TB_HYKGL_KZXX.class;
		Annotation[] classAnnotions = c.getAnnotations();
		for(Annotation a : classAnnotions) {
			if (a instanceof Entity) {
				String tableName = ((Entity)a).name();	// 数据库中表的名称
				System.out.println("tableName="+tableName);
				if (tableName == null || tableName.length() == 0) {
					tableName = c.getSimpleName().toUpperCase();	// 数据库中表的字段名称
				}
				System.out.println("tableName="+tableName);
			} 
			
			System.out.println("classAnnotion="+a);
		}
		
		ArrayList<Field> list = new ArrayList<Field>();
		for (; c != Object.class; c = c.getSuperclass()) {
			for (Field item : c.getDeclaredFields()) {
				list.add(item);
			}
		}
		 
		for (Field classField : list) {
			String classFieldName = classField.getName(); 
			Annotation[] annotions = classField.getAnnotations();
			boolean show = true;
			for(Annotation a : annotions) {
				if (a instanceof Column){
					show = false; 
				} 
				System.out.println(classFieldName+" ="+a);
			}
			if(show){
				System.out.println(classFieldName );
			}
		}
		
		System.out.println(Modifier.FINAL + Modifier.STATIC + Modifier.PUBLIC);
		System.out.println(Modifier.FINAL + Modifier.STATIC + Modifier.PRIVATE);
		System.out.println(Modifier.FINAL + Modifier.STATIC + Modifier.PROTECTED);
		System.out.println(Modifier.FINAL + Modifier.STATIC  );
		System.out.println(Modifier.STATIC  );
	}

}
